﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            Page.Form.DefaultFocus = txtUserName.ClientID;
            Page.Form.DefaultButton = cmdLogin.UniqueID;
        }

    }
    protected void cmdLogin_Click(object sender, EventArgs e)
    {
        //check for valid page
        if (!Page.IsValid) { return; }

        //Clear session for new user
        Session.Clear();

        //Save the user id to the Session
        Session["userID"] =  txtUserName.Text;

        // Goto default page unless a different path is requested
        string path = "Default.aspx";
        if (Request.Params["returnTo"] != null)
        {
            path = Request.Params["returnTo"];
        }

        Response.Redirect(path);
    }
}
